package proxy.jdk.service.proxy;



import proxy.jdk.service.AccountService;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class AccountAdvise implements InvocationHandler {
  // 目标对象
  private AccountService accountService;

  public AccountAdvise(AccountService accountService) {
    this.accountService = accountService;
  }

  /**
   * 代理方法，每次调用方法都会进来这里
   * @param proxy
   * @param method
   * @param args
   * @return
   * @throws Throwable
   */
  @Override
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    before();
    return method.invoke(accountService,args);
  }

  private void before() {
    System.out.println("转账业务的身份认证");
  }
}
